Public Enum EncryptionMethod : TripleDES : Rinjdael : RC2 : RC4 : XOREncryption : End Enum
    Public Enum EncryptionType : Encrypt : Decrypt : End Enum

    Public Shared Function Cryptography(ByVal Method As EncryptionMethod, ByVal Type As EncryptionType, _
    ByVal InputString As String, Optional ByVal Key As String = "[Eprouvez]") As String
        Select Case Method
            Case EncryptionMethod.Rinjdael
                Dim bytIV() As Byte = {121, 241, 10, 1, 132, 74, 11, 39, 255, 91, 45, 78, 14, 211, 22, 62}
                Select Case Type
                    Case EncryptionType.Encrypt
                        Dim PlainText() As Byte
                        Dim Encoded() As Byte
                        Dim MemoryStream As New MemoryStream
                        Dim RijndaelManaged As New RijndaelManaged
                        InputString = InputString.Replace(vbNullChar, String.Empty)
                        PlainText = Encoding.UTF8.GetBytes(InputString)
                        Dim CryptoStream As New CryptoStream(MemoryStream, _
                            RijndaelManaged.CreateEncryptor(Encoding.ASCII.GetBytes(Key), bytIV), _
                            CryptoStreamMode.Write)
                        CryptoStream.Write(PlainText, 0, PlainText.Length)
                        CryptoStream.FlushFinalBlock()
                        Encoded = MemoryStream.ToArray
                        MemoryStream.Close()
                        CryptoStream.Close()
                        Return Convert.ToBase64String(Encoded)
                    Case EncryptionType.Decrypt
                        Dim CryptText() As Byte
                        Dim RijndaelManaged As New RijndaelManaged
                        CryptText = Convert.FromBase64String(InputString)
                        Dim Temp(CryptText.Length) As Byte
                        Dim MemoryStream As New MemoryStream(CryptText)

                        Dim CryptoStream As New CryptoStream(MemoryStream, _
                            RijndaelManaged.CreateDecryptor(Encoding.ASCII.GetBytes(Key), bytIV), _
                            CryptoStreamMode.Read)
                        CryptoStream.Read(Temp, 0, Temp.Length)
                        MemoryStream.Close()
                        CryptoStream.Close()
                        Return Encoding.UTF8.GetString(Temp).Replace(vbNullChar, String.Empty)
                End Select
            Case EncryptionMethod.RC2
                Select Case Type
                    Case EncryptionType.Encrypt
                        Dim DES As New Security.Cryptography.RC2CryptoServiceProvider
                        DES.IV = New Byte(7) {}
                        Dim PDB As New Security.Cryptography.PasswordDeriveBytes(Key, New Byte(-1) {})
                        DES.Key = PDB.CryptDeriveKey("RC2", "MD5", 128, New Byte(7) {})
                        Dim MemS As New IO.MemoryStream((InputString.Length * 2) - 1)
                        Dim Stream As New Security.Cryptography.CryptoStream(MemS, DES.CreateEncryptor(), Security.Cryptography.CryptoStreamMode.Write)
                        Dim Bytes As Byte() = Encoding.UTF8.GetBytes(InputString)
                        Stream.Write(Bytes, 0, Bytes.Length)
                        Stream.FlushFinalBlock()
                        Dim Enc(CInt(MemS.Length - 1)) As Byte
                        MemS.Position = 0
                        MemS.Read(Enc, 0, CInt(MemS.Length))
                        Stream.Close()
                        Return Convert.ToBase64String(Enc)
                    Case EncryptionType.Decrypt
                        Dim DES As New Security.Cryptography.RC2CryptoServiceProvider
                        DES.IV = New Byte(7) {}
                        Dim PDB As New Security.Cryptography.PasswordDeriveBytes(Key, New Byte(-1) {})
                        DES.Key = PDB.CryptDeriveKey("RC2", "MD5", 128, New Byte(7) {})
                        Dim Bytes As Byte() = Convert.FromBase64String(InputString)
                        Dim MemS As New IO.MemoryStream(InputString.Length)
                        Dim Stream As New Security.Cryptography.CryptoStream(MemS, DES.CreateDecryptor(), Security.Cryptography.CryptoStreamMode.Write)
                        Stream.Write(Bytes, 0, Bytes.Length)
                        Stream.FlushFinalBlock()
                        Dim Bytes2(CInt(MemS.Length - 1)) As Byte
                        MemS.Position = 0
                        MemS.Read(Bytes2, 0, CInt(MemS.Length))
                        Stream.Close()
                        Return Encoding.UTF8.GetString(Bytes2)
                End Select
            Case EncryptionMethod.XOREncryption
                Select Case Type
                    Case EncryptionType.Encrypt
                        Dim DataPtr As Long = Nothing
                        Dim DataOut As String = Nothing
                        Dim XOrValue As Integer, XOrValue1 As Integer
                        For lonDataPtr = 1 To Len(InputString)
                            XOrValue = Asc(Mid$(InputString, lonDataPtr, 1))
                            XOrValue1 = Asc(Mid$(Key, ((lonDataPtr Mod Len(Key)) + 1), 1))
                            DataOut = DataOut + Chr(XOrValue Xor XOrValue1)
                        Next lonDataPtr
                        Return DataOut
                    Case EncryptionType.Decrypt
                        Dim Sbuilder As New StringBuilder()
                        For i As Integer = 0 To InputString.Length
                            Sbuilder.Append(Chr(i Xor ((i Mod 5) + 1)))
                        Next
                        Return Sbuilder.ToString()
                End Select
            Case EncryptionMethod.RC4
                Dim Int As Integer = 0
                Dim j As Integer = 0
                Dim Cipher As New StringBuilder
                Dim ReturnCipher As String = String.Empty
                Dim Sbox As Integer() = New Integer(256) {}
                Dim Keys As Integer() = New Integer(256) {}
                Dim intLength As Integer = Key.Length
                Dim a As Integer = 0
                While a <= 255
                    Dim ctmp As Char = (Key.Substring((a Mod intLength), 1).ToCharArray()(0))
                    Keys(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
                    Sbox(a) = a
                    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
                End While
                Dim x As Integer = 0
                Dim b As Integer = 0
                While b <= 255
                    x = (x + Sbox(b) + Keys(b)) Mod 256
                    Dim tempSwap As Integer = Sbox(b)
                    Sbox(b) = Sbox(x)
                    Sbox(x) = tempSwap
                    System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
                End While
                a = 1
                While a <= InputString.Length
                    Dim itmp As Integer = 0
                    Int = (Int + 1) Mod 256
                    j = (j + Sbox(Int)) Mod 256
                    itmp = Sbox(Int)
                    Sbox(Int) = Sbox(j)
                    Sbox(j) = itmp
                    Dim k As Integer = Sbox((Sbox(Int) + Sbox(j)) Mod 256)
                    Dim ctmp As Char = InputString.Substring(a - 1, 1).ToCharArray()(0)
                    itmp = Asc(ctmp)
                    Dim cipherby As Integer = itmp Xor k
                    Cipher.Append(Chr(cipherby))
                    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
                End While
                ReturnCipher = Cipher.ToString
                Cipher.Length = 0
                Return ReturnCipher
            Case EncryptionMethod.TripleDES
                Select Case Type
                    Case EncryptionType.Encrypt
                        Dim DES As New Security.Cryptography.TripleDESCryptoServiceProvider
                        DES.IV = New Byte(7) {}
                        Dim PDB As New Security.Cryptography.PasswordDeriveBytes(Key, New Byte(-1) {})
                        DES.Key = PDB.CryptDeriveKey("RC2", "MD5", 128, New Byte(7) {})
                        Dim MemS As New IO.MemoryStream((InputString.Length * 2) - 1)
                        Dim Stream As New Security.Cryptography.CryptoStream(MemS, DES.CreateEncryptor(), Security.Cryptography.CryptoStreamMode.Write)
                        Dim Bytes As Byte() = Encoding.UTF8.GetBytes(InputString)
                        Stream.Write(Bytes, 0, Bytes.Length)
                        Stream.FlushFinalBlock()
                        Dim Enc(CInt(MemS.Length - 1)) As Byte
                        MemS.Position = 0
                        MemS.Read(Enc, 0, CInt(MemS.Length))
                        Stream.Close()
                        Return Convert.ToBase64String(Enc)
                    Case EncryptionType.Decrypt
                        Dim DES As New Security.Cryptography.TripleDESCryptoServiceProvider
                        DES.IV = New Byte(7) {}
                        Dim PDB As New Security.Cryptography.PasswordDeriveBytes(Key, New Byte(-1) {})
                        DES.Key = PDB.CryptDeriveKey("RC2", "MD5", 128, New Byte(7) {})
                        Dim Bytes As Byte() = Convert.FromBase64String(InputString)
                        Dim MemS As New IO.MemoryStream(InputString.Length)
                        Dim Stream As New Security.Cryptography.CryptoStream(MemS, DES.CreateDecryptor(), Security.Cryptography.CryptoStreamMode.Write)
                        Stream.Write(Bytes, 0, Bytes.Length)
                        Stream.FlushFinalBlock()
                        Dim Bytes2(CInt(MemS.Length - 1)) As Byte
                        MemS.Position = 0
                        MemS.Read(Bytes2, 0, CInt(MemS.Length))
                        Stream.Close()
                        Return Encoding.UTF8.GetString(Bytes2)
                End Select
        End Select
        Return Nothing
    End Function
    Public Enum HashMethod : MD5 : SHA1 : SHA256 : SHA384 : SHA512 : End Enum